﻿
namespace CmdArgs.Validation
{
    using System.Collections.Generic;
    using System.ComponentModel;
    using CmdArgs.Settings;

    /// <summary>
    /// Represents validation error, it consists of 
    /// error message and list of options which are invalid.
    /// </summary>
    [ImmutableObject(true)]
    public sealed class ValidationError
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ValidationError"/> class.
        /// </summary>
        /// <param name="message">The error message.</param>
        /// <param name="invalidOptions">The list of invalid options.</param>
        public ValidationError(string message, IEnumerable<OptionSettings> invalidOptions)
        {
            this.Message = message;
            this.InvalidOptions = invalidOptions;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ValidationError"/> class.
        /// Overloaded version of the other constructor.
        /// </summary>
        /// <param name="message">The error message.</param>
        /// <param name="option">The invalid option.</param>
        public ValidationError(string message, OptionSettings option)
            : this(message, new[] { option }) 
        { 
        }

        /// <summary>
        /// Gets the error message.
        /// </summary>
        public string Message { get; private set; }

        /// <summary>
        /// Gets the list of invalid options.
        /// 'Invalid options' means options that caused this validation error.
        /// </summary>
        public IEnumerable<OptionSettings> InvalidOptions { get; private set; }

        public override bool Equals(object obj)
        {
            // TODO - immutable object
            return base.Equals(obj);
        }

        public override int GetHashCode()
        {
            // TODO - immutable object
            return base.GetHashCode();
        }
    }
}
